package fr.labri.harmony.analysis.jsep.results.filter;

import java.io.IOException;
import java.io.PrintStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import fr.labri.harmony.analysis.jsep.results.LoadRules;

public class MigrationTestPrecision extends ResultFilter {

	@Override
	public void computeResult(ResultSet rs) throws SQLException, IOException {
		rs.first();
		PrintStream ps = new PrintStream(System.out);
		int	correct = 0;
		int wrong = 0;

		while (rs.next()){		
			String source = rs.getString("NAME");
			String target = rs.getString("MIGRATION_LIB_TO");
			if(target != null) {
				int length = rs.getInt("MIGRATION_LENGTH");
				int nb1 = rs.getInt("migration_nb_fichiers_in");
				int nb2 = rs.getInt("migration_nb_fichiers_out");
				int diff = Math.abs(nb2-nb1);
				if(length==1 && diff==0) {
					if(LoadRules.isTrueRule(source, target)) {
						correct++;
					}
					else
						wrong++;
				}
			}
		}
		ps.println("Correct "+correct);
		ps.println("Wrong "+wrong);
	}

}

